//
//  OrderViewController.m
//  SXH
//
//  Created by Jack on 15/9/1.
//  Copyright (c) 2015年 lyss. All rights reserved.
//

#import "OrderViewController.h"
#import "HMSegmentedControl.h"
#import "OrderTableViewCell.h"
#import "CommonService.h"
#import "UIButton+WebCache.h"
#import "OrderEntity.h"
#import "OrderProductEntity.h"
#import "MZTimerLabel.h"
#import "ALiPay.h"
#import "WXPay.h"
#import "LocalProductDetailViewController.h"
#import "RouteDetailViewController.h"
#import "MainTbaBarController.h"
#import "MJRefresh.h"
#import "OrderHasPaidViewController.h"
#import "OrderDetailViewController.h"
@interface OrderViewController ()<MZTimerLabelDelegate>
{
    MZTimerLabel *timer;
}

@property (nonatomic, strong) NSMutableArray *mutableArrayOrder;
@property (nonatomic, strong) IBOutlet UIView *viewOrder;
@property (nonatomic, strong) IBOutlet UIView *orderViewNeedPaid;
@property (nonatomic, strong) IBOutlet UITableView *tableViewOrder;
@property (nonatomic, strong) OrderHasPaidViewController *orderHasPaidView;

@property NSInteger segmentedIndex;
@property NSInteger operationIndex;

@end

@implementation OrderViewController
@synthesize mutableArrayOrder,tableViewOrder,viewOrder,orderViewNeedPaid,orderHasPaidView;
@synthesize userId;
@synthesize segmentedIndex;
@synthesize orderFlag;
@synthesize wrapperMainVC;

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    mutableArrayOrder = [[NSMutableArray alloc] init];
    orderHasPaidView = [[OrderHasPaidViewController alloc]init];
    [self.viewOrder addSubview:orderHasPaidView.view];
    [self addChildViewController:orderHasPaidView];
    HMSegmentedControl *segmentedControl = [[HMSegmentedControl alloc] initWithSectionTitles:@[@"未付款", @"已付款"]];
    [segmentedControl setIndexChangeBlock:^(NSUInteger index) {
        if (index == 0) {
            orderViewNeedPaid.hidden = NO;
            orderHasPaidView.view.hidden = YES;
            viewOrder.hidden = ([mutableArrayOrder count] == 0)?YES:NO;
        } else if (index == 1) {
            viewOrder.hidden = NO;
            orderHasPaidView.view.hidden = NO;
            orderViewNeedPaid.hidden = YES;
        }
        NSLog(@"Selected index %lu (via block)", (unsigned long)index);
    }];
    
    [segmentedControl setSelectionIndicatorHeight:1.0f];
    [segmentedControl setBackgroundColor:[UIColor whiteColor]];
    [segmentedControl setTextColor:[UIColor darkGrayColor]];
    [segmentedControl setSelectionIndicatorColor:[UIColor colorWithRed:0.55 green:0.77 blue:0.2 alpha:1]];
    [segmentedControl setSelectionIndicatorMode:HMSelectionIndicatorFillsSegment];
    [segmentedControl setSegmentEdgeInset:UIEdgeInsetsMake(0, 6, 0, 6)];
    [segmentedControl setCenter:CGPointMake(160, 120)];
    [segmentedControl setTag:2];
    segmentedControl.frame = CGRectMake(0, 66, SCREEN_WIDTH, 40);
    [self.view addSubview:segmentedControl];
    
    [self initMutableArrayOrder];//加载本地订单
    if(!orderFlag){
        orderViewNeedPaid.hidden = NO;
        orderHasPaidView.view.hidden = YES;
        viewOrder.hidden = ([mutableArrayOrder count] == 0)?YES:NO;
    }else{
        viewOrder.hidden = NO;
        orderHasPaidView.view.hidden = NO;
        orderViewNeedPaid.hidden = YES;
        [segmentedControl setSelectedIndex:1];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

-(void)initMutableArrayOrder{
    NSUserDefaults *orderEntity = [NSUserDefaults standardUserDefaults];
    //可以用alloc 方法代替
    NSMutableArray *mutableArrayOrderTemp = [NSMutableArray arrayWithArray:[orderEntity objectForKey:@"OrderEntityList"]];
    for(int i=0;i<[mutableArrayOrderTemp count];i++){
        OrderEntity *orderEntity = [NSKeyedUnarchiver unarchiveObjectWithData:[mutableArrayOrderTemp objectAtIndex:i]];
        if(orderEntity){
            [mutableArrayOrder addObject:orderEntity];
        }
    }
    viewOrder.hidden = ([mutableArrayOrder count] == 0)?YES:NO;
    [tableViewOrder reloadData];
}

- (void)segmentedControlChangedValue:(HMSegmentedControl *)segmentedControl {
    NSLog(@"Selected index %li (via UIControlEventValueChanged)", (long)segmentedControl.selectedIndex);
}

#pragma mark -
#pragma mark Table view data source

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    // Return the number of rows in the section.
    return 1;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    // Return the number of sections.
    return [mutableArrayOrder count];
}

#pragma mark - tableView headView
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 60.0;
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView *headView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 60)];
    headView.backgroundColor = [UIColor colorWithRed:1 green:1 blue:1 alpha:1];
    
    UILabel *timerLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, 60, 20)];
    timerLabel.textColor = [UIColor redColor];
    timerLabel.font = [UIFont systemFontOfSize:13];
    timerLabel.text = @"00:00:00";
    
    UILabel *timerLabelName = [[UILabel alloc] initWithFrame:CGRectMake(70, 0, 200, 20)];
    timerLabelName.textColor = [UIColor redColor];//darkGrayColor
    timerLabelName.font = [UIFont systemFontOfSize:13];
    timerLabelName.text = @"后,系统自动取消订单";
    
    UIImage *image = [UIImage imageNamed:@"店铺.png"];
    UIImageView *businessLogo = [[UIImageView alloc] initWithFrame:CGRectMake(10, 32, 15, 15)];
    [businessLogo setImage:image];
    
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(40, 20, 250, 40)];
    titleLabel.backgroundColor = [UIColor clearColor];
    titleLabel.textColor = [UIColor darkGrayColor];
    titleLabel.font = [UIFont systemFontOfSize:13];
    
    UIImage *imageArrow = [UIImage imageNamed:@"右_02.png"];
    UIImageView *arrowView = [[UIImageView alloc] initWithFrame:CGRectMake(300, 32, 15, 15)];
    [arrowView setImage:imageArrow];
    
    UILabel *orderTagLabel = [[UILabel alloc] initWithFrame:CGRectMake(headView.frame.size.width-60, 20, 150, 40)];
    orderTagLabel.backgroundColor = [UIColor clearColor];
    orderTagLabel.textColor = [UIColor darkGrayColor];
    orderTagLabel.font = [UIFont systemFontOfSize:13];
    
    if([mutableArrayOrder count] >0){
        OrderEntity *entity = [mutableArrayOrder objectAtIndex:section];
        titleLabel.text = ([entity.store_name isEqualToString:@""])?@"乐游山水网络科技有限公司":entity.store_name;
        orderTagLabel.text = ([entity.status isEqualToString:@"102"])?@"已付款":@"未付款";
        //开启定时器
        NSDate *datenow = [NSDate date];
        NSDateFormatter * dateFormat = [[NSDateFormatter alloc]init];
        //指定输出的格式   这里格式必须是和上面定义字符串的格式相同，否则输出空
        [dateFormat setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
        NSDate *olddate =[dateFormat dateFromString:entity.insert_time];
        long dd = (long)[datenow timeIntervalSince1970] - [olddate timeIntervalSince1970];
        timer = [[MZTimerLabel alloc] initWithLabel:timerLabel andTimerType:MZTimerLabelTypeTimer];
        [timer setCountDownTime:(600-dd)];
        timer.delegate = self;
        [timer start];
        
        [headView addSubview:timerLabel];
        [headView addSubview:timerLabelName];
    }
    
    [headView addSubview:businessLogo];
    [headView addSubview:titleLabel];
    //[headView addSubview:arrowView];
    [headView addSubview:orderTagLabel];
    
    return headView;
}

#pragma mark - tableView footView
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 50.0;
}

-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    UIView *footView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 90)];
    footView.backgroundColor = [UIColor colorWithRed:1 green:1 blue:1 alpha:1];//[UIColor blackColor];
    
//    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width-10, 39)];
//    titleLabel.backgroundColor = [UIColor clearColor];
//    titleLabel.textColor = [UIColor darkGrayColor];
//    titleLabel.font = [UIFont systemFontOfSize:13];
//    titleLabel.textAlignment = NSTextAlignmentRight;
    
    UILabel *lineLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 1)];
    lineLabel.backgroundColor = [UIColor colorWithRed:0.95 green:0.93 blue:0.92 alpha:1];
    
    UIButton *delOrder = [[UIButton alloc] initWithFrame:CGRectMake(self.view.frame.size.width-180, 5, 80, 30)];
    [delOrder.layer setCornerRadius:5.0]; //设置矩形四个圆角半径
    [delOrder.layer setBorderWidth:1.0]; //边框宽度
    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    CGColorRef colorref = CGColorCreate(colorSpace,(CGFloat[]){ 0.9, 0.9, 0.9, 1 });
    [delOrder.layer setBorderColor:colorref];//边框颜色
    [delOrder setTitle: @"删除订单" forState: UIControlStateNormal];
    delOrder.titleLabel.font = [UIFont systemFontOfSize: 14.0];
    //    [delOrder setBackgroundColor: [UIColor blueColor]];
    [delOrder setTitleColor:[UIColor blackColor]forState:UIControlStateNormal];
    [delOrder addTarget:self action:@selector(delOrder:) forControlEvents:UIControlEventTouchUpInside];
    delOrder.tag = section;
    
    //    UIButton *getLogistics =[[UIButton alloc] initWithFrame:CGRectMake(self.view.frame.size.width-180, 45, 80, 30)];
    //    [getLogistics.layer setCornerRadius:5.0]; //设置矩形四个圆角半径
    //    [getLogistics.layer setBorderWidth:1.0]; //边框宽度
    //    [getLogistics.layer setBorderColor:colorref];//边框颜色
    //    [getLogistics setTitle: @"查看物流" forState: UIControlStateNormal];
    //    getLogistics.titleLabel.font = [UIFont systemFontOfSize: 14.0];
    ////    [getLogistics setBackgroundColor: [UIColor blueColor]];
    //    [getLogistics setTitleColor:[UIColor blackColor]forState:UIControlStateNormal];
    
    UIButton *orderPay =[[UIButton alloc] initWithFrame:CGRectMake(self.view.frame.size.width-90, 5, 80, 30)];
    [orderPay.layer setCornerRadius:5.0]; //设置矩形四个圆角半径
    [orderPay.layer setBorderWidth:1.0]; //边框宽度
    [orderPay.layer setBorderColor:colorref];//边框颜色
    orderPay.titleLabel.font = [UIFont systemFontOfSize: 14.0];
    [orderPay setTitleColor:[UIColor blackColor]forState:UIControlStateNormal];
    
    UILabel *lineLabel2 = [[UILabel alloc] initWithFrame:CGRectMake(0, 40, self.view.frame.size.width, 1)];
    lineLabel2.backgroundColor = [UIColor colorWithRed:0.95 green:0.95 blue:0.95 alpha:1];
    
    UILabel *lineLabel3 = [[UILabel alloc] initWithFrame:CGRectMake(0, 41, self.view.frame.size.width, 10)];
    lineLabel3.backgroundColor = [UIColor colorWithRed:0.95 green:0.93 blue:0.92 alpha:1];
    
    if([mutableArrayOrder count] >0){
        OrderEntity *entity = [mutableArrayOrder objectAtIndex:section];
//        titleLabel.text = [NSString stringWithFormat:@"%@%@%@%@%@",@"合计: ¥ ",entity.total_amount,@" (含运费: ¥ ",entity.ship_cost,@")"];
    }
    
//    [footView addSubview:titleLabel];
    [footView addSubview:lineLabel];
    [orderPay setTitle: @"去支付" forState: UIControlStateNormal];
    [orderPay addTarget:self action:@selector(payOrder:) forControlEvents:UIControlEventTouchUpInside];
    orderPay.tag = section;
    [footView addSubview:delOrder];
    
    [footView addSubview:orderPay];
    //    [footView addSubview:getLogistics];
    [footView addSubview:lineLabel2];
    //    [footView addSubview:lineLabel3];
    
    return footView;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *couponTableViewCellIdentifier=@"OrderTableViewCell";
    OrderTableViewCell *cell = (OrderTableViewCell *)[tableView dequeueReusableCellWithIdentifier:couponTableViewCellIdentifier];
    if (cell == nil) {
        NSArray *array = [[NSBundle mainBundle] loadNibNamed:@"OrderTableViewCell" owner:self options:nil];
        cell = [array objectAtIndex:0];
    }
    
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
//    if([mutableArrayOrder count] > 0){
//        NSLog(@"indexPath is = %li",(long)indexPath.section);
//        OrderEntity *entity = [mutableArrayOrder objectAtIndex:indexPath.section];
//        
//        for (int i = 0; i < [entity.product_list count]; i++) {
//            OrderProductEntity *productEntity = [entity.product_list objectAtIndex:i];
//            cell.productName.text = productEntity.product_name;
//            //            [cell.productImage sd_setBackgroundImageWithURL:[NSURL URLWithString:productEntity.album_thumb] forState:UIControlStateNormal];
//            [cell.productImage sd_setImageWithURL:[NSURL URLWithString:productEntity.album_thumb] forState:UIControlStateNormal];
//            cell.introduce.text = productEntity.introduce;
//            cell.goodsCnt.text = [NSString stringWithFormat:@"%@%@",@"x ",productEntity.count];
//            cell.price.text = [NSString stringWithFormat:@"¥%@",productEntity.price];
//            cell.priceLabel.text = [NSString stringWithFormat:@"¥%@",entity.total_amount];
//            cell.total_peopleLabel.text = [NSString stringWithFormat:@"%@",[productEntity.tourism_data objectForKey:@"total_people"]]; ;
//            cell.departure_dateLabel.text = [productEntity.tourism_data objectForKey:@"departure_date"];
//        }
//    }
    if([mutableArrayOrder count] > 0){
        NSLog(@"indexPath is = %li",(long)indexPath.section);
        OrderEntity *entity = [mutableArrayOrder objectAtIndex:indexPath.section];
        
        for (int i = 0; i < [entity.product_list count]; i++) {
            OrderProductEntity *productEntity = [entity.product_list objectAtIndex:i];
            cell.productName.text = productEntity.product_name;
            //            [cell.productImage sd_setBackgroundImageWithURL:[NSURL URLWithString:productEntity.album_thumb] forState:UIControlStateNormal];
            [cell.productImage sd_setImageWithURL:[NSURL URLWithString:productEntity.album_thumb] forState:UIControlStateNormal];
            cell.introduce.text = productEntity.introduce;
            cell.goodsCnt.text = [NSString stringWithFormat:@"%@%@",@"x ",productEntity.count];
            cell.price.text = [NSString stringWithFormat:@"¥%@",productEntity.price];
        }
    }

    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 100;
}

#pragma mark -
#pragma mark Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
//    RouteDetailViewController *rvc=[[RouteDetailViewController alloc]init];
//    LocalProductDetailViewController *lpvc=[[LocalProductDetailViewController alloc]init];
    OrderEntity *orderEntity = [mutableArrayOrder objectAtIndex:indexPath.section];
//    OrderProductEntity *productEntity = [orderEntity.product_list objectAtIndex:0];
//    NSString *product_id=productEntity.product_id;
//    if([orderEntity.order_class isEqualToString:@"1"]){
//        RouteEntity *routeEntityTemp=[[RouteEntity alloc]init];
//        routeEntityTemp.t_id=product_id;
//        rvc.routeEntity = routeEntityTemp;
//        [self.navigationController pushViewController:rvc animated:YES];
//    }else if([orderEntity.order_class isEqualToString:@"2"]){
//        LPEntity *wrapEntityTemp=[[LPEntity alloc]init];
//        wrapEntityTemp.ID=product_id;
//        lpvc.wrapEntity = wrapEntityTemp;
//        [self.navigationController pushViewController:lpvc animated:YES];
//    }
    OrderDetailViewController *mvc = [[OrderDetailViewController alloc]init];
    mvc.order_id = orderEntity.ID;
    [self.navigationController pushViewController:mvc animated:YES];
}

//删除未支付的订单
-(void)delOrder:(UIButton*)btn{
    self.operationIndex=btn.tag;
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"删除订单" message:@"是否要删除该订单？" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
    alert.tag = 90009;
    [alert show];
}
//TODO:支付未付款订单
-(void)payOrder:(UIButton*)btn{
    NSUserDefaults *orderDefault = [NSUserDefaults standardUserDefaults];
    //可以用alloc 方法代替
    NSMutableArray *mutableArray = [NSMutableArray arrayWithArray:[orderDefault objectForKey:@"OrderEntityList"]];
    OrderEntity *orderEntity = [NSKeyedUnarchiver unarchiveObjectWithData:[mutableArray objectAtIndex:btn.tag]];
    
    //    NSData *orderData = [[NSUserDefaults standardUserDefaults] objectForKey:@"OrderEntity"];
    //    OrderEntity *orderEntity = [NSKeyedUnarchiver unarchiveObjectWithData:orderData];
    if(orderEntity){
        NSString *product_name;
        NSString *introduce;
        NSString *total_amount;
        for (int i = 0; i < [orderEntity.product_list count]; i++) {
            OrderProductEntity *productEntity = [orderEntity.product_list objectAtIndex:i];
            product_name = productEntity.product_name;
            introduce = productEntity.introduce;
            total_amount = productEntity.price;
        }
        if([orderEntity.payWay isEqualToString:@"2"]){
            //TODO:微信创建订单
            WXPay *wxPay=[[WXPay alloc]init];
            //本地处理签名
            //                                  [wxPay sendPay:[dic objectForKey:@"order_num"] productName:@"乐游山水" amount:@"1" VC:self];
            //服务器端处理签名
            NSUserDefaults *wxBlockDict = [NSUserDefaults standardUserDefaults];
            NSDictionary *dic = [wxBlockDict objectForKey:@"wxBlockDict"];
            [wxPay sendPay:dic VC:self];
        }else{
            //TODO:支付宝创建订单
            ALiPay *alipay=[[ALiPay alloc]init];
            if([orderEntity.order_class isEqualToString:@"3"]){
                [alipay postOrder:orderEntity.order_num productName:product_name productDescription:introduce amount:orderEntity.total_amount VC:self orderFlag:@"new"];
            }else{
                [alipay postOrder:orderEntity.order_num productName:product_name productDescription:introduce amount:orderEntity.total_amount VC:self orderFlag:@"old"];
            }
        }
    }
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
    if (alertView.tag == 90009) {
        if (buttonIndex == 1) {
            [mutableArrayOrder removeObjectAtIndex:self.operationIndex];
            NSMutableArray *mutableArrayTemp=[[NSMutableArray alloc]init];
            for(int i=0;i<[mutableArrayOrder count];i++){
                NSData *data = [NSKeyedArchiver archivedDataWithRootObject:[mutableArrayOrder objectAtIndex:i]];
                [mutableArrayTemp addObject:data];
            }
            
            NSUserDefaults *orderDefault = [NSUserDefaults standardUserDefaults];
            //记住要转换成不可变数组类型
            NSArray * array = [NSArray arrayWithArray:mutableArrayTemp];
            [orderDefault setObject:array forKey:@"OrderEntityList"];
            
            [tableViewOrder reloadData];
            viewOrder.hidden = ([mutableArrayOrder count] == 0)?YES:NO;
        }
    }
}

//10min未付款，自动删除订单
-(void)timerLabel:(MZTimerLabel*)timerLabel finshedCountDownTimerWithTime:(NSTimeInterval)countTime{
    if([mutableArrayOrder count]>0){
        [mutableArrayOrder removeObjectAtIndex:0];
        NSMutableArray *mutableArrayTemp=[[NSMutableArray alloc]init];
        for(int i=0;i<[mutableArrayOrder count];i++){
            NSData *data = [NSKeyedArchiver archivedDataWithRootObject:[mutableArrayOrder objectAtIndex:i]];
            [mutableArrayTemp addObject:data];
        }
        NSUserDefaults *orderDefault = [NSUserDefaults standardUserDefaults];
        //记住要转换成不可变数组类型
        NSArray * array = [NSArray arrayWithArray:mutableArrayTemp];
        [orderDefault setObject:array forKey:@"OrderEntityList"];
    }else{
        NSUserDefaults *orderDefault = [NSUserDefaults standardUserDefaults];
        [orderDefault removeObjectForKey:@"OrderEntityList"];
    }
    
    [tableViewOrder reloadData];
    viewOrder.hidden = ([mutableArrayOrder count] == 0)?YES:NO;
}
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
//    if(!orderFlag){
//        viewOrder.hidden = ([mutableArrayOrder count] == 0)?YES:NO;
//    }else{
//        viewOrder.hidden = NO;
//    }
    [MobClick beginLogPageView:@"OrderViewController"];
}
- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    [MobClick endLogPageView:@"OrderViewController"];
}

//返回个人中心页面
-(IBAction)backMeCenter:(id)sender{
    //发送通知
    NSNotification *notification = [NSNotification notificationWithName:@"BACK_MECENTER_NOTIFICATION" object:@"3"];
    [[NSNotificationCenter defaultCenter] postNotification:notification];
    [self.navigationController popToRootViewControllerAnimated:YES];
}

//去掉UItableview headerview黏性(sticky)
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    if (scrollView == self.tableViewOrder)
    {
        CGFloat sectionHeaderHeight = 60; //sectionHeaderHeight
        if (scrollView.contentOffset.y<=sectionHeaderHeight&&scrollView.contentOffset.y>=0) {
            scrollView.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0);
        } else if (scrollView.contentOffset.y>=sectionHeaderHeight) {
            scrollView.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight, 0, 0, 0);
        }
    }
}

@end
